package com.example.demo.service.impl;

import com.example.demo.dao.CourseMaterialDao;
import com.example.demo.entity.CourseMaterialBean;
import com.example.demo.service.CourseMaterialService;
import com.example.demo.util.PageEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseMaterialServiceImpl implements CourseMaterialService {
    @Autowired
    private CourseMaterialDao courseMaterialDao;

    @Override
    public Integer add(CourseMaterialBean courseMaterialBean) {
        return courseMaterialDao.add(courseMaterialBean);
    }

    @Override
    public Integer update(CourseMaterialBean courseMaterialBean) {
        return courseMaterialDao.update(courseMaterialBean);
    }

    @Override
    public Integer delete(Integer id) {
        return courseMaterialDao.delete(id);
    }

    @Override
    public CourseMaterialBean one(Integer id) {
        return courseMaterialDao.getOneById(id);
    }

    @Override
    public PageEntity list(Integer pageNo, Integer pageSize, String name, String sortOrder) {
        Integer count = courseMaterialDao.count(name);
        List<CourseMaterialBean> list = courseMaterialDao.list(name, sortOrder);
        return new PageEntity<>(list, count);
    }
} 